package com.jacobson.huobi.mvp.presenter

import com.jacobson.core.di.annotation.ActivityScope
import com.jacobson.core.mvp.BasePresenter
import com.jacobson.huobi.common.expansion.applySchedulersIoMain
import com.jacobson.huobi.common.expansion.onResponseResult
import com.jacobson.huobi.entities.vo.KycAuthResVo
import com.jacobson.huobi.mvp.contract.KycAuthContract
import okhttp3.MultipartBody
import javax.inject.Inject

@ActivityScope
class KycAuthPresenter @Inject constructor(
    view: KycAuthContract.View,
    model: KycAuthContract.Model
) : BasePresenter<KycAuthContract.View, KycAuthContract.Model>(view, model),
    KycAuthContract.Presenter {
    override fun submitKycAuth(kycAuthResVo: KycAuthResVo) {
        model.submitKycAuth(kycAuthResVo)
            .applySchedulersIoMain()
            .onResponseResult(view) { resp ->
                view?.onSubmitKycAuthResultResp(resp)
            }
    }

    override fun loadKycDetail(width: Int) {
        model.loadKycDetail(width)
            .applySchedulersIoMain()
            .onResponseResult(view) { resp ->
                view?.onLoadKycDetailResultResp(resp)
            }
    }

    override fun kycUpload(file: MultipartBody.Part, side: String, width: Int) {
        model.kycUpload(file, side, width)
            .applySchedulersIoMain()
            .onResponseResult(view) { resp ->
                view?.onKycUploadResultResp(resp)
            }
    }
}
